package org.swfer.UIC 
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	/**
	 * 列表渲染单元
	 * @author swfer
	 */
	public class ListRenderItem extends Component implements IRenderItem
	{
		protected var _data:Object;
		protected var _selected:Boolean;
		
		public function ListRenderItem(view:MovieClip) 
		{
			super(view);
		}
		
		override protected function init():void
		{
			view.buttonMode = true;
			view.mouseChildren = false;
		}
		
		override protected function addEvt():void
		{
			if (view.totalFrames == 1) return;
			
			view.addEventListener(MouseEvent.ROLL_OVER,onRollOver);
			view.addEventListener(MouseEvent.ROLL_OUT,onRollOut);
		}
		
		override protected function removeEvt():void
		{
			if (view.totalFrames == 1) return;
			
			view.removeEventListener(MouseEvent.ROLL_OVER,onRollOver);
			view.removeEventListener(MouseEvent.ROLL_OUT,onRollOut);
		}
		
		private function onRollOut(e:MouseEvent):void 
		{
			if (_selected) return;
			view.gotoAndStop(1);
		}
		
		private function onRollOver(e:MouseEvent):void 
		{
			if (_selected) return;
			view.gotoAndStop(2);
		}
		
		public function get data():Object { return _data}; 
		public function set data(value:Object):void
		{
			_data = value;
			injectData = value;
		}
		
		public function get selected():Boolean {return _selected;}
		public function set selected(value:Boolean):void 
		{
			_selected = value;
			if (view.totalFrames == 1) return;
			value?view.gotoAndStop(view.totalFrames):view.gotoAndStop(1);
		}
	}
}